<template>
	<view class="">
		<!-- 上面动态切换 -->
		<view class="title-view">
			<text @tap="changeIndex(index)" class="text-view" :class="{'active':currentIndex==index}"
				v-for="(item,index) in list" :key="item">{{item}}</text>
		</view>

		<!-- 下面滑块 -->
		<swiper :current="currentIndex" @change="changetab">
			<swiper-item v-for="item in swiper" :key="item">{{item}}</swiper-item>
		</swiper>
	</view>

</template>

<script>
	export default {
		data() {
			return {
				list: ["热门", "销量", "价格"],
				swiper: ["A", "B", "C"],
				currentIndex: 0,
			}
		},
		methods: {
			changeIndex(index) {
				this.currentIndex = index;
			},
			changetab(e){
				this.currentIndex=e.detail.current;
			}
		}
	}
</script>

<style>
	.title-view {
		display: flex;
	}

	.text-view {
		flex-grow: 1;
		line-height: 80rpx;
		text-align: center;
	}

	.active {
		border-bottom: 5rpx solid #5992BD;
	}
</style>
